<template>
	<view>
		<u-navbar placeholder fixed autoBack border title="人员考勤">
			<view slot="right"><u-icon name="search" size="20" color="#162233"></u-icon></view>
		</u-navbar>

		<view class="d-p-30">
			<view class="card d-p-30">
				<view class="d-font-32" style="font-weight: bold;color: #323334;">考勤概览</view>
				<view class="d-flex d-m-t-20 d-font-24 d-text-center" style="color: #4E5C70;">
					<view class="d-flex-1">
						<view>实名总人数</view>
						<view class="d-m-t-10" style="color: #21A5F3;font-weight: bold;font-size: 42rpx;">{{ count ? count.staffs : 0 }}</view>
					</view>
					<view class="d-flex-1">
						<view>进场总人数</view>
						<view class="d-m-t-10" style="color: #21A5F3;font-weight: bold;font-size: 42rpx;">{{ count ? count.istaffs : 0 }}</view>
					</view>
					<view class="d-flex-1">
						<view>缺勤总人数</view>
						<view class="d-m-t-10" style="color: #21A5F3;font-weight: bold;font-size: 42rpx;">{{ count ? count.unatdStaffs : 0 }}</view>
					</view>
				</view>
			</view>

			<view class="d-m-t-30 card d-p-30" v-for="(item, index) in list" :key="index" @click="workGroupMemberDetail(item)">
				<view class="d-flex">
					<view class="d-font-28" style="font-weight: bold;color: #151C24;">{{ item.xm }}</view>
					<view class="d-font-28 d-m-l-70" style="color: #5D6672;">{{ item.xb }}</view>
					<view class="d-m-l-20 d-m-r-20"><u-line direction="col" length="36rpx" color="#DFDFDF"></u-line></view>
					<view class="tag d-flex">{{ item.smrz }}</view>
					<view class="d-m-l-20 d-m-r-20"><u-line direction="col" length="36rpx" color="#DFDFDF"></u-line></view>
					<view class="d-font-28" style="color: #21A5F3;">{{ item.ryzt }}</view>
					<view class="d-flex-1"></view>
					<!-- <view class="d-flex">
						<text class="d-font-24" style="color: #ADB4BD;position: relative;top: -2rpx;">详情</text>
						<u-icon name="arrow-right" size="24rpx" color="#ADB4BD"></u-icon>
					</view> -->
				</view>
				<view class="d-flex d-font-24 d-m-t-20">
					<view class="d-flex" style="flex: 3;">
						<view class="d-m-r-20" style="color: #5D6672;">公民身份号码</view>
						<view style="color: #162233;">{{ item.zjhm | str }}</view>
					</view>
					<view class="d-flex" style="flex: 2;">
						<view class="d-m-r-20" style="color: #5D6672;">所属区划</view>
						<view style="color: #162233;">{{ item.districtName }}</view>
					</view>
				</view>
				<view class="d-flex d-font-24 d-m-t-20">
					<view class="d-flex" style="flex: 3;">
						<view class="d-m-r-20" style="color: #5D6672;">项目名称</view>
						<view class="d-flex-1" style="color: #162233;">{{ item.gcmc }}</view>
					</view>
				</view>
				<view class="d-flex d-font-24 d-m-t-20">
					<view class="d-flex" style="flex: 3;">
						<view class="d-m-r-20" style="color: #5D6672;">班组名称</view>
						<view class="d-flex-1" style="color: #162233;">{{ item.bzmc }}</view>
					</view>
					<view class="d-flex" style="flex: 2;">
						<view class="d-m-r-20" style="color: #5D6672;">从事工种</view>
						<view style="color: #162233;">{{ item.zwzc }}</view>
					</view>
				</view>
				<view class="d-flex d-font-24 d-m-t-20">
					<view class="d-flex" style="flex: 3;">
						<view class="d-m-r-20" style="color: #5D6672;">本月工资</view>
						<view style="color: #ADB4BD;">{{ item.salary }}</view>
					</view>
					<view class="d-flex" style="flex: 2;">
						<view class="d-m-r-20" style="color: #5D6672;">当天考勤</view>
						<view style="color: #ADB4BD;">{{ item.attendance }}</view>
					</view>
				</view>
			</view>

			<template v-if="!list || list.length <= 0">
				<view><u-empty icon="/static/image/none.png" :text="'暂无数据'"></u-empty></view>
			</template>
		</view>
	</view>
</template>

<script>
import { staffsStatistics, staffs } from '../../../common/api.js';
export default {
	data() {
		return {
			bzid: null,
			gcbh: null,
			count: null,
			pageNum: 1,
			pageSize: 20,
			pageLast: 1,
			list: [],
		};
	},
	onReachBottom() {
		if (this.pageNum < this.pageLast) {
			++this.pageNum;
			this.getList().then(e => {
				this.list = this.list.concat(e.data);
			});
		}
	},
	onLoad(e) {
		this.bzid = e.id;
		this.gcbh = e.gcbh;
		this.init();
	},
	methods: {
		init() {
			staffsStatistics({
				params: {
					gcbh: this.gcbh,
					bzbh: this.bzid
				}
			}).then(e => {
				this.count = e.data;
			});
			this.pageNum = 1;
			this.getList().then(e => {
				this.list = e.data;
				this.pageLast = Math.ceil(e.total / this.pageSize);
			});
		},
		getList() {
			return staffs({
				params: {
					deptId: this.$user.deptId,
					pageSize: this.pageSize,
					pageNum: this.pageNum,
					bzid: this.bzid,
					gcbh: this.gcbh
				}
			});
		},
		workGroupMemberDetail(item) {
			uni.$u.route({
				url: '/pages/index/work/workGroupMemberDetail',
				params: {
					bzid: item.bzid,
					rybh: item.id,
					name: item.xm,
					zwzc: item.zwzc,
					gcbh: this.gcbh
				}
			});
		}
	}
};
</script>

<style lang="scss">
.card {
	box-shadow: 0rpx 5rpx 10rpx rgba(0, 0, 0, 0.05);
	border-radius: 10rpx;
	background-color: #ffffff;
	.tag {
		height: 32rpx;
		background: #ffb61d;
		border-radius: 4rpx;
		color: #ffffff;
		font-size: 20rpx;
		padding: 0 10rpx;
	}
}
page {
	background-color: #fbfcfc;
}
</style>
